package co.fitstart.weapp.api.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.core.persistence.annotation.Dao;

import co.fitstart.entity.order.Order;
import co.fitstart.entity.order.OrderType;
import co.fitstart.entity.order.PaymentStatus;
import co.fitstart.entity.user.User;
import co.fitstart.entity.user.agent.Agent;
import co.fitstart.weapp.api.dao.OrderDao;
import co.fitstart.weapp.api.service.OrderService;

/**
 * 
 * @author dan
 *
 */
@Service("orderService")
public class OrderServiceImpl implements OrderService{
    
    @Dao
    private OrderDao orderDao;
    
    @Autowired
    private GenericDaoSupport genericDaoSupport;
    
    /*
     * (non-Javadoc)
     * @see co.fitstart.weapp.api.service.OrderService#listAgentOrder(co.fitstart.entity.order.OrderType, co.fitstart.entity.user.agent.Agent)
     */
    public List<Order> listAgentOrder(OrderType orderType, Agent agent) {
        return orderDao.list(orderType, agent, PaymentStatus.PAID);
    }
    
    /*
     * (non-Javadoc)
     * @see co.fitstart.weapp.api.service.OrderService#list(co.fitstart.entity.user.User, co.fitstart.entity.order.PaymentStatus)
     */
    public List<Order> list(User user, PaymentStatus paymentStatus) {
        return orderDao.list(user, paymentStatus);
    }
    
    /*
     * (non-Javadoc)
     * @see co.fitstart.weapp.api.service.OrderService#load(java.lang.Long)
     */
    public Order load(Long id) {
        return genericDaoSupport.load(Order.class, id);
    }

}
